package com.tech.koufu.ui.activity.setting;

import org.w3c.dom.Text;

import com.tech.koufu.R;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

public class AboutActiviity extends Activity{

	private TextView tv_title;
	private TextView txt_about;
	private TextView app_version;
	private ImageView img_callback;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about);
		initView();
	}

	private void initView(){
		tv_title = (TextView)findViewById(R.id.tv_title);
		tv_title.setVisibility(View.VISIBLE);
		tv_title.setText("关于");
		txt_about = (TextView)findViewById(R.id.txt_about);
		txt_about.setText(R.string.text_about);
		app_version = (TextView)findViewById(R.id.app_version);
		app_version.setText("版本号:" + getVersionCode(getApplicationContext()));
		img_callback = (ImageView)findViewById(R.id.img_callback);
		img_callback.setVisibility(View.VISIBLE);
		img_callback.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				AboutActiviity.this.finish();	
			}
		});
	}

	public static String getVersionCode(Context context) {
		return getPackageInfo(context).versionName;
	}

	private static PackageInfo getPackageInfo(Context context) {
		PackageInfo pi = null;

		try {
			PackageManager pm = context.getPackageManager();
			pi = pm.getPackageInfo(context.getPackageName(),
					PackageManager.GET_CONFIGURATIONS);

			return pi;
		} catch (Exception e) {
			e.printStackTrace();
		}

		return pi;
	}
}
